package com.whater.wechat.rest.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONArray;
import com.whater.common.domain.AjaxResult;
import com.whater.wechat.service.ImageService;
import com.whater.wechat.service.VideoService;

import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("wechat")
@Slf4j
public class WeChatController {
	
	@Autowired
	private ImageService imageService;
	
	@Autowired
	private VideoService videoService;

	@GetMapping("image/listPath")
	public AjaxResult listPath(@RequestParam(name = "path") String path) {
		return AjaxResult.success(imageService.getPath(path));
	}

	@GetMapping("image/listImage")
	public AjaxResult listImage(@RequestParam(name = "path") String path,
			@RequestParam(name = "skip") Integer skip,
			@RequestParam(name = "limit") Integer limit,
			@RequestParam(name = "includeOptData") boolean includeOptData,
			@RequestParam(name = "selectedData") boolean  selectedData ) {
		return imageService.getImage(path,skip,limit,includeOptData,selectedData);
	}
	
	@PostMapping("image/submit")
	public AjaxResult submit(@RequestBody JSONArray data) {
		return imageService.submit(data);
	}
	@PostMapping("image/export")
	public AjaxResult exportImage(@RequestBody JSONArray data) {
		return imageService.export(data);
	}

	
	@GetMapping("video/listPath")
	public AjaxResult listPath2(@RequestParam(name = "path") String path) {
		return AjaxResult.success(videoService.getPath(path));
	}
	
	@GetMapping("video/listImage")
	public AjaxResult listImage2(@RequestParam(name = "path") String path,
			@RequestParam(name = "skip") Integer skip,
			@RequestParam(name = "limit") Integer limit,
			@RequestParam(name = "includeOptData") boolean includeOptData,
			@RequestParam(name = "selectedData") boolean  selectedData ) {
		return videoService.getImage(path,skip,limit,includeOptData,selectedData);
	}
	
	@PostMapping("video/submit")
	public AjaxResult submit2(@RequestBody JSONArray data) {
		return videoService.submit(data);
	}
	
	
	@PostMapping("video/export")
	public AjaxResult exportVideo(@RequestBody JSONArray data) {
		return videoService.export(data);
	}
	
	
}
